package com.qing.demo.netty.server;

import com.qing.demo.netty.codec.ObjDecoder;
import com.qing.demo.netty.codec.ObjEncoder;
import com.qing.demo.netty.domain.MsgInfo;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
import io.netty.handler.codec.Delimiters;
import io.netty.handler.codec.FixedLengthFrameDecoder;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

import java.nio.charset.Charset;


/**
 * @author caozhipeng
 * @date 2025/7/25
 */
public class MyChannelInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline().addLast(new ObjDecoder(MsgInfo.class));
        socketChannel.pipeline().addLast(new ObjEncoder(MsgInfo.class));
        socketChannel.pipeline().addLast(new MyServerHandler());
    }
}
